<?php
function sub_str($str, $length = 0, $append = true)

{

    $str = trim($str);

    $strlength = strlen($str);

 

    if ($length == 0 || $length >= $strlength)

    {

        return $str;

    }

    elseif ($length < 0)

    {

        $length = $strlength + $length;

        if ($length < 0)

        {

            $length = $strlength;

        }

    }

 

    if (function_exists('mb_substr'))

    {

        $newstr = mb_substr($str, 0, $length, 'utf-8');

    }

    elseif (function_exists('iconv_substr'))

    {

        $newstr = iconv_substr($str, 0, $length, 'utf-8');

    }

    else

    {

        //$newstr = trim_right(substr($str, 0, $length));

        $newstr = substr($str, 0, $length);

    }

 

    if ($append && $str != $newstr)

    {

        $newstr .= '...';

    }

 

    return $newstr;

}
function set_admin_session($user_id, $username, $action_list, $last_time)
{
    $_SESSION['admin_id']    = $user_id;
    $_SESSION['admin_name']  = $username;
    $_SESSION['action_list'] = $action_list;
    $_SESSION['last_check']  = $last_time; // 用于保存最后一次检查订单的时间
}

function gmtime()
{
    return time();
}

?>